﻿
Imports sonicERPDAL
Imports sonicERPinfo

Partial Public Class ucMENU
    Inherits System.Web.UI.UserControl


    Dim idnivel As Integer
#Region "Sub e Funções"

    Public Sub menu()


        Dim l As New ArrayList
        l.Add(menus.Home)
        l.Add(menus.Sistema)
        l.Add(menus.Cadastro_de_Nivel_de_Usuario)
        l.Add(menus.Lista_do_Nivel_do_Usuario)
        l.Add(menus.Lista_de_Usuario)
        l.Add(menus.Cadastro_usuario)
        l.Add(menus.Alterar_Senha)
        For index As Integer = 1 To l.Count

            Dim dal As New menuDAL
            Dim menu As New Menu
            menu.idnivel = idnivel
            menu.idmenu = Convert.ToInt32(index)
            dal.lista1(menu)
            If index = menus.Home Then
                a1.Visible = menu.visible
            End If
            If index = menus.Sistema Then
                a2.Visible = menu.visible
            End If
            If index = menus.Cadastro_de_Nivel_de_Usuario Then
                a3.Visible = menu.visible
            End If
            If index = menus.Lista_do_Nivel_do_Usuario Then
                a4.Visible = menu.visible
            End If

            If index = menus.Lista_de_Usuario Then
                a5.Visible = menu.visible
            End If
            If index = menus.Cadastro_usuario Then
                a6.Visible = menu.visible
            End If
            If index = menus.Alterar_Senha Then
                a7.Visible = menu.visible
            End If
        Next

    End Sub


    Public Enum menus As Integer
        Home = 1
        Sistema = 2
        Cadastro_de_Nivel_de_Usuario = 3
        Lista_do_Nivel_do_Usuario = 4
        Lista_de_Usuario = 5
        Cadastro_usuario = 6
        Alterar_Senha = 7
    End Enum
#End Region

#Region "Eventos da Master Page"


    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            idnivel = Convert.ToInt32(Application("idnivel").ToString)


            menu()
        End If
    End Sub


    Private Sub a1_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles a1.ServerClick
        Response.Redirect(ResolveUrl("~/Home.aspx"))
    End Sub
    Private Sub a2_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles a2.ServerClick

    End Sub

    Private Sub a3_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles a3.ServerClick
        Response.Redirect(ResolveUrl("~/Cadastronivel.aspx"))
    End Sub

    Private Sub a4_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles a4.ServerClick
        Response.Redirect(ResolveUrl("~/NivelLista.aspx"))
    End Sub

    Private Sub a5_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles a5.ServerClick
        Response.Redirect(ResolveUrl("~/UsuarioLista.aspx"))
    End Sub

    Private Sub a6_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles a6.ServerClick
        Response.Redirect(ResolveUrl("~/CadastroUsuario.aspx"))
    End Sub

    Private Sub a7_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles a7.ServerClick
        Response.Redirect(ResolveUrl("~/Alterarsenha.aspx"))
    End Sub

#End Region


End Class
